import { createApp } from 'vue'
import router from "./router/index.js";
import { getAuthRoutes } from "./router/permission";
import pinia from "./store/index.js";
import i18n from "./locale";
import * as Icons from "@vicons/ionicons5";

import "normalize.css/normalize.css";
import "animate.css/animate.min.css";
import "./assets/css/base.css";
import "vfonts/FiraCode.css";

import {
  create,
  NButton,
  NLayout,
  NLayoutHeader,
  NLayoutSider,
  NDivider,
  NConfigProvider,
  NLayoutFooter,
  NH2,
  NIcon,
  NMenu
} from "naive-ui";

import App from './App.vue'


const naive = create({
  components: [
    NButton,
    NLayout,
    NLayoutSider,
    NLayoutHeader,
    NDivider,
    NConfigProvider,
    NLayoutFooter,
    NH2,
    NIcon,
    NMenu
  ],
});

/** 权限路由处理主方法 */
getAuthRoutes().then(() => {
  const app = createApp(App);
  app.use(pinia);
  app.use(router);
  app.use(naive);
  app.use(i18n);
  app.mount("#app");
  // 注册全局组件
  Object.keys(Icons).forEach((key) => {
    app.component(key, Icons[key]);
  });
})